/**
 * ENGLISH MASS UNITS
 * Contains OUNCES, POUNDS, STONES, HUNDREDWEIGHTS, TONS
 * METRIC BASE: GRAMS
 * Each unit is set up as:
 * 
 * UNITS {
 * 
 * 	-- Returns value in same units --
 * 	public double toUnits(double value){
 * 		return value;
 * 	}
 * 
 * 	-- Returns value in other units --
 * 	-- One method for each type in category --
 * 	-- Example: UNITS = INCHES, value = 18, Convert toFeet, Return = 1.5 (Feet)
 * 	public double toOtherUnits(double value){
 * 		return value ( / or * ) ####;
 * 	}
 * 		
 * 	-- Converts value value of Unit type sourceUnit into UNITS type --
 * 	-- Example: UNITS = INCHES, value = 1.5, sourceUnit = FEET, return = 18 (Inches)
 * 	public double convert (double value, EnglishUnit sourceUnit){
 * 		return sourceUnit.toUnits(value);
 *	}
 * }
 */

package umuc.cmsc495.mach2.unit.english;

/**
 * @author Michael Swann
 */
public enum EnglishMassUnit {
    OUNCES {
	@Override
	public double toOunces(double value) {
	    return value;
	}

	@Override
	public double toPounds(double value) {
	    return value / 16;
	}

	@Override
	public double toStones(double value) {
	    return value / 224;
	}

	@Override
	public double toHundredweights(double value) {
	    return value / 1600;
	}

	@Override
	public double toTons(double value) {
	    return value / 32000;
	}

	@Override
	public double toGrams(double value) {
	    return value * 28.3495231648;
	}

	@Override
	public double convert(double value, EnglishMassUnit sourceUnit) {
	    return sourceUnit.toOunces(value);
	}
    },

    POUNDS {
	@Override
	public double toOunces(double value) {
	    return value * 16;
	}

	@Override
	public double toPounds(double value) {
	    return value;
	}

	@Override
	public double toStones(double value) {
	    return value / 14;
	}

	@Override
	public double toHundredweights(double value) {
	    return value / 100;
	}

	@Override
	public double toTons(double value) {
	    return value / 2000;
	}

	@Override
	public double toGrams(double value) {
	    return value * 453.5923703803;
	}

	@Override
	public double convert(double value, EnglishMassUnit sourceUnit) {
	    return sourceUnit.toPounds(value);
	}
    },

    STONES {
	@Override
	public double toOunces(double value) {
	    return value * 224;
	}

	@Override
	public double toPounds(double value) {
	    return value * 14;
	}

	@Override
	public double toStones(double value) {
	    return value;
	}

	@Override
	public double toHundredweights(double value) {
	    return value / 7.1428571431;
	}

	@Override
	public double toTons(double value) {
	    return value / 142.8571429789;
	}

	@Override
	public double toGrams(double value) {
	    return value * 6350.2931799100;
	}

	@Override
	public double convert(double value, EnglishMassUnit sourceUnit) {
	    return sourceUnit.toStones(value);
	}
    },

    HUNDREDWEIGHTS {
	@Override
	public double toOunces(double value) {
	    return value * 1600;
	}

	@Override
	public double toPounds(double value) {
	    return value * 100;
	}

	@Override
	public double toStones(double value) {
	    return value * 7.1428571431;
	}

	@Override
	public double toHundredweights(double value) {
	    return value;
	}

	@Override
	public double toTons(double value) {
	    return value / 20;
	}

	@Override
	public double toGrams(double value) {
	    return value * 45359.2370010035;
	}

	@Override
	public double convert(double value, EnglishMassUnit sourceUnit) {
	    return sourceUnit.toHundredweights(value);
	}
    },

    TONS {
	@Override
	public double toOunces(double value) {
	    return value * 32000;
	}

	@Override
	public double toPounds(double value) {
	    return value * 2000;
	}

	@Override
	public double toStones(double value) {
	    return value * 142.8571429789;
	}

	@Override
	public double toHundredweights(double value) {
	    return value * 20;
	}

	@Override
	public double toTons(double value) {
	    return value;
	}

	@Override
	public double toGrams(double value) {
	    return value * 907184.740760757;
	}

	@Override
	public double convert(double value, EnglishMassUnit sourceUnit) {
	    return sourceUnit.toTons(value);
	}
    };

    /**
     * @param sourceValve
     *            Value in Source Units
     * @param sourceUnit
     *            Source Unit Type
     * @return Value in Target Units
     */
    public abstract double toOunces(double value);

    public abstract double toPounds(double value);

    public abstract double toStones(double value);

    public abstract double toHundredweights(double value);

    public abstract double toTons(double value);

    public abstract double toGrams(double value);

    public abstract double convert(double sourceValve, EnglishMassUnit sourceUnit);
}